﻿using Digitalmes.Domain;

namespace Digitalmes.Infrastructure.Scada.Handlers;

/// <summary>
/// 日志记录帮助对象。
/// </summary>
internal static class LoggerHelper
{
    public static ScadaResult LogAndReturn(ILogger logger, string msgHeader, string wsCode, ErrorCode errCode)
    {
        var result = ScadaResult.Error(errCode);
        logger.LogWarning("[{MsgHeader}] 工位：{WsCode}，状态: {State}, 消息: [{InnerErrorCode}]-{ErrMessage}",
                msgHeader,
                wsCode,
                result.State.ToString(),
                result.InnerErrorCode.ToString(),
                result.GetErrorMessage());

        return result;
    }
}
